﻿<common:LayoutAwarePage x:Class="StoreAppLibDemo.MainPage"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:StoreAppLibDemo_XamlTypeInfo="using:StoreAppLibDemo.StoreAppLibDemo_XamlTypeInfo"
                        xmlns:ViewModel="using:StoreAppLibDemo.ViewModel"
                        xmlns:common="using:StoreAppLibDemo.Common"
                        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                        xmlns:local="using:StoreAppLibDemo"
                        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                        mc:Ignorable="d"
                        NavigationCacheMode="Enabled">

    <Page.DataContext>
        <ViewModel:MainPageView />
    </Page.DataContext>

    <Page.Resources>
        <CollectionViewSource x:Name="dataSource"
                              IsSourceGrouped="true"
                              Source="{Binding LibraryGroup}"
                              d:Source="{Binding LibraryGroup,
                                                 Source={d:DesignInstance Type=ViewModel:MainPageView,
                                                                          IsDesignTimeCreatable=True}}" />
    </Page.Resources>

    <Grid Style="{StaticResource AppPageStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="40" />
            <RowDefinition />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Grid.Column="1"
                   Margin="0,0,50,0"
                   Source="Assets/PageLogo.png" />
            <TextBlock Margin="120,0,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Bottom"
                       Style="{StaticResource HeaderTextStyle}"
                       Text="Windows Store Application Library"
                       TextWrapping="Wrap" />

        </Grid>

        <TextBlock Grid.Row="3"
                   Margin="0,0,50,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Center"
                   FontSize="9"
                   Text="Copyright ©  2012 Suresh Kumar T" />
        <GridView Grid.Row="2"
                  IsItemClickEnabled="True"
                  ItemsSource="{Binding Source={StaticResource dataSource}}"
                  Padding="120,0,0,0"
                  SelectionMode="None">
            <GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>
            <GridView.ItemTemplate>
                <DataTemplate>
                    <Grid Width="298"
                          Height="130"
                          Background="#FF2B82CB"
                          Tapped="OnLibraryTapped">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Grid.ColumnSpan="2"
                                BorderBrush="White"
                                BorderThickness="2" />
                        <Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="2" Background="#FF1375C7"/>
                        <TextBlock
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Text="{Binding Name}"
                                   TextWrapping="Wrap" Grid.ColumnSpan="2" Margin="10,0,0,0" />
                        <Image Grid.Row="1" Source="{Binding Image}" Margin="10"/>
                        <TextBlock TextWrapping="Wrap" Text="{Binding Description}" Margin="0,5,5,5" Grid.Row="1" Grid.Column="1" FontSize="13.333"/>
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>
            <GridView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Margin="0,0,0,10"
                                       Style="{StaticResource SubheaderTextStyle}"
                                       Text="{Binding Key}" />
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid Margin="0,0,80,0" Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </GridView.GroupStyle>
        </GridView>

    </Grid>
</common:LayoutAwarePage>
